<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    <div id="app">
        <p>vue中数组的监听</p>
        <span v-for="(num, index) in arr1" >{{num}}</span><br>
        <p v-for="(num, index) in arr3" >
            <span v-for="(item, index) in num">{{item}},</span>
        </p>
        <p v-for="(phone, index) in arr2" >
            {{phone.name}}--{{phone.price}}
        </p>
        <p>
            第一种情况：通过下标修改数组的一整项<br>
            第二种情况：通过数组本身的长度修改数组<br>
            解决方案一：splice(index,length,newValue)/splice(newLength)<br>
            解决方案二：vm.$set(vm.arr,index,vlaue)/Vue.set(arr,index,value)
        </p>
        <hr>
        <p>vue中对象的监听</p>
        <p v-for="(val,key, index) in obj1" >
            {{index+1}}.{{key}}:{{val}}
        </p>
        <p>第一种情况：新增对象的属性</p>
        <p>第二种情况：删除对象的属性</p>
        <p>修改属性可以被监听到</p>
        <p>新增：vm.$set(vm.obj1,'num',150)/Vue.set(vm.obj1,'num',150)</p>
        <p>删除：Vue.delete(vm.obj1,'num')</p>
    </div>
    <script src="./js/vue.js"></script>
    <script>
        let vm = new Vue({
            el:'#app',
            data:{
                arr1:[
                    1,2,3,4,5
                ],
                arr2:[
                    {
                        name:'iphone 11',
                        price:'6666'
                    },
                    {
                        name:'iphone 12',
                        price:'6999'
                    },
                    {
                        name:'iphone 13',
                        price:'5666'
                    },
                    {
                        name:'iphone 14',
                        price:'5999'
                    },
                    {
                        name:'iphone 15',
                        price:'7999'
                    },
                    {
                        name:'iphone 16',
                        price:'8999'
                    },
                    
                ],
                arr3:[
                    [
                        1,2,3,4,5
                    ],
                    [
                        1,2,3,4,5
                    ],
                    [
                        1,2,3,4,5
                    ],
                ],

                obj1:{
                    name:'iphone 16',
                    price:'8999'
                }
            },
            computed: {
                
            },
            methods: {
                
            },
            
        })
    </script>
</body>
</html>